<template>
  <div>
    <van-nav-bar
      fixed
      placeholder
      safe-area-inset-top
      title="城市列表"
      left-arrow
      @click-left="back"
    />
    <van-cell
      v-for="(item, index) in citylist"
      :key="index"
      :title="item.name"
      @click="jumptoindex(item.name, item.adcode, item.citycode)"
    />
  </div>
</template>

<script>
import { get19citylist } from '@/apis/buy.js'
import { setChooseCityQualify } from '@/utils/auth'
export default {
  data() {
    return {
      citylist: []
    }
  },
  created() {
    this.getcity()
  },
  methods: {
    back() {
      this.$router.go(-1)
    },
    async getcity() {
      await get19citylist({}).then((res) => {
        this.citylist = res.result.list
      })
    },
    jumptoindex(city, adCode, cityCode) {
      setChooseCityQualify(cityCode, city, adCode)
      this.$router.back()
      setTimeout(()=>{
        window.location.reload()
      },100)
    }
  }
}
</script>

<style lang="less" scoped>
</style>
